<script setup lang="ts">
import useBookmarks from '../../use-bookmarks'
import useTabs from '../../use-tabs'

const { bookmarks } = useBookmarks()
const { tabs, startCreateTab } = useTabs()
</script>

<template>
  <div class="start">
    <div v-if="tabs.length === 0" class="start__navs">
      <div class="start__nav" v-for="b in bookmarks" :key="b.url" @click="startCreateTab(b.url)">
        <img :src="b.favicon" :alt="b.title" />
        <span class="start__nav__title">{{ b.title }}</span>
      </div>
    </div>
  </div>
</template>

<style scoped>
.start {
  box-sizing: border-box;
  width: 100%;
  height: 0;
  flex-grow: 1;
  border-top: 1px solid var(--border-color-base);
  display: flex;
  justify-content: center;
  align-items: center;
}
.start__navs {
  width: 40%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-lg);
}
.start__nav {
  box-sizing: border-box;
  flex: 0;
  flex-grow: 1;
  max-width: 25%;
  aspect-ratio: 2 / 1;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-lg);
}
.start__nav:hover {
  border-radius: var(--border-radius-lg);
  background: var(--color-gray-3);
  cursor: pointer;
}
.start__nav__title {
  width: 100%;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>
